package com.x_memteor.base_master.bean.request;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.x_memteor.base_master.base.BaseRequestEntity;
import com.x_memteor.base_master.utils.AesEncodeUtil;
import com.x_memteor.base_master.utils.GsonUtils;
import com.x_memteor.base_master.utils.LogUtils;

/**
 * @author: X_Meteor
 * @description: 类描述
 * @version: V_1.0.0
 * @date: 2018/4/7 22:29
 * @company:
 * @email: lx802315@163.com
 */
public class MeasureBody extends BaseRequestEntity {

    String mac;
    String code;
    Long time;
    String sign;
    String weight;
    String mr;

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getMr() {
        return mr;
    }

    public void setMr(String mr) {
        this.mr = mr;
    }

    public MeasureBody(Long time) {
        if (String.valueOf(time).length() > 10) {
            this.time = Long.valueOf(String.valueOf(time).substring(0, 10));
        }
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }


    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        if (String.valueOf(time).length() > 10) {
            this.time = Long.valueOf(String.valueOf(time).substring(0, 10));
        }else if (String .valueOf(time).length() == 10){
            this.time = time;
        }else {
            this.time = time;
        }
    }

    Gson mGson;

    @Override
    public String getSign() {
        if (mGson == null) {
            mGson = GsonUtils.getInstance();
        }
        if (TextUtils.isEmpty(sign)) {
            sign = AesEncodeUtil.encrypt(mGson.toJson(this));
        }
        LogUtils.print(AesEncodeUtil.decrypt(sign));
        return sign;
    }

    @Override
    public String getCiphertext() {
        return null;
    }
}
